package org.nox.helloseries.core.connector.tracker.impl;

import org.jdom2.Element;
import org.nox.helloseries.core.connector.tracker.AbstractRSSTorrentSearch;
import org.nox.helloseries.core.util.HelloSeriesConstants;
import org.nox.helloseries.domain.NomTracker;
import org.nox.helloseries.domain.Serie;

public class EztvSearch extends AbstractRSSTorrentSearch
{
    private final String BASE_URL = "http://www.ezrss.it/search/index.php?simple&mode=rss&";

    @Override
    protected int getSeeds( Element e )
    {
        return HelloSeriesConstants.MAGIC_SEEDS;
    }

    @Override
    protected double getTailleFichier( Element e )
    {
        return Double.parseDouble( e.getChild( "enclosure" ).getAttributeValue( "length" ) ) / 1000000;
    }

    @Override
    protected String getTitre( Element e )
    {
        return e.getChildText( "title" );
    }

    @Override
    protected String getUrl( Element e )
    {
        return e.getChild( "enclosure" ).getAttributeValue( "url" );
    }

    @Override
    protected String getUrlRecherche( Serie serie )
    {
        return BASE_URL + "show_name=" + serie.getNom().replaceAll( " ", "+" ) + "&episode=" + serie.getEpisode() + "&season=" + serie.getSaison();
    }

    @Override
    protected NomTracker getNomTracker()
    {
        return NomTracker.EZTV;
    }

}
